var groupAdd = {
}

$(function(){
	changeActiveItem('groupList');
	savehandle();
});

function savehandle(){
	$('#alertdiv').hide();
	$('#alertdiv').savehandle({
		fieldMap:{},
		successMsg: '保存成功！',
		failMsg: '保存失败，请重试！错误：',
		success:successCallBack
	});
}

function successCallBack(){
	location.href = 'groupList.jsp';
}
/**
 * 提交数据
 * @return {TypeName} 
 */
function add() {
	//验证组名
	var groupName = $("#groupAdd .content #groupName").val();
	//验证备注
	var remarks = $("#groupAdd .content #remarks").val();
	//获取基本信息
	var datas = {
		"groupName":groupName,
		"remarks":remarks,
		"loginUrl": $("#groupAdd .content #loginUrl").val()
	};
	for(var o in datas){
		if(!datas[o] && "0" != datas[o])
			delete(datas[o]);
	}
	if(!$('#groupForm').validate()){
		$('#alertdiv').savehandle('setmsg',{msg:'请完善输入信息!'});
		return false;
	}

	$.getJSON(
		'/fw/auth/group_add.action',
		datas,
		function(data){
			$('#alertdiv').savehandle('handle',data,2000);
		}
	);
}

/**
 * 重写reSet函数
 */
function reSet() {
	$('#groupAdd #groupForm #groupName').val('');
	$('#groupAdd #groupForm #remarks').val('');
}

